# 用net表示cell的pin之间的连接关系，对应图结构，cell是点，net是路径，有向无权图

from pin_item import Pin

class Net:
    
    def __init__(self,name = "",pin_count = 0) -> None:
        self.name = name
        self.pin_count = pin_count
        self.bits = ["x"] * pin_count
        self.hide_name = 0
        self.attributes = {}
        pass
    
    def set_bit(self,bit,index=0):
        self.bits[index] = bit
    
    def get_pin_count(self):
        return self.pin_count
    def get_name(self):
        return self.name
    def get_bit(self,index=0):
        return self.bits[index]
    def set_attribute(self,name,value):
        self.attributes[name] = value

    def to_dict(self):
        data = dict()
        data["hide_name"] = self.hide_name
        data["bits"] = self.bits
        if len(self.attributes) > 0:
            data["attributes"] = self.attributes
        return data
